import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:tvlives/config/Global.dart';
import 'package:tvlives/pages/Splash_Page.dart';
import 'package:tvlives/provider/provider.dart';
import 'package:tvlives/route/Application.dart';
import 'package:tvlives/values/theme_colors.dart';
void main() {
  Global.init().then((e) => runApp(MultiProvider(
    providers: [
      ChangeNotifierProvider<CategoryList>.value(value: Global.categorys),
      ChangeNotifierProvider<ThemeInfo>.value(value: Global.themeInfo)
    ],
    child: Consumer<ThemeInfo>(
      builder: (
      context,themeInfo,_
      ){
        return MyApp(themeInfo.themeColor);
      },
    ),
  ),
  ),
  );
}

class MyApp extends StatelessWidget{
  final String themeColor;
  MyApp(this.themeColor);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      onGenerateRoute: Application.router.generator,
       title:"live tv",
      theme: ThemeData(
        primaryColor:ThemeColors.themeColor[themeColor]["primaryColor"],
        primaryColorDark: ThemeColors.themeColor[themeColor]["primaryColorDark"],
        accentColor: ThemeColors.themeColor[themeColor]["colorAccent"]
      ),
      debugShowCheckedModeBanner: false,
      home: SplashPage(),
    );
  }

}

